import { Scalar as o } from '../../nodes/Scalar.js';
import { map as a } from '../common/map.js';
import { seq as s } from '../common/seq.js';
function n(t) {
  return typeof t == 'bigint' || Number.isInteger(t);
}
const e = ({ value: t }) => JSON.stringify(t),
  l = [
    {
      identify: t => typeof t == 'string',
      default: !0,
      tag: 'tag:yaml.org,2002:str',
      resolve: t => t,
      stringify: e,
    },
    {
      identify: t => t == null,
      createNode: () => new o(null),
      default: !0,
      tag: 'tag:yaml.org,2002:null',
      test: /^null$/,
      resolve: () => null,
      stringify: e,
    },
    {
      identify: t => typeof t == 'boolean',
      default: !0,
      tag: 'tag:yaml.org,2002:bool',
      test: /^true|false$/,
      resolve: t => t === 'true',
      stringify: e,
    },
    {
      identify: n,
      default: !0,
      tag: 'tag:yaml.org,2002:int',
      test: /^-?(?:0|[1-9][0-9]*)$/,
      resolve: (t, r, { intAsBigInt: i }) => (i ? BigInt(t) : parseInt(t, 10)),
      stringify: ({ value: t }) => (n(t) ? t.toString() : JSON.stringify(t)),
    },
    {
      identify: t => typeof t == 'number',
      default: !0,
      tag: 'tag:yaml.org,2002:float',
      test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
      resolve: t => parseFloat(t),
      stringify: e,
    },
  ],
  f = {
    default: !0,
    tag: '',
    test: /^/,
    resolve(t, r) {
      return r(`Unresolved plain scalar ${JSON.stringify(t)}`), t;
    },
  },
  m = [a, s].concat(l, f);
export { m as schema };
